jQuery(document).ready(function ($) {
	var i = 0;
	var interval;
	$('#checkbox').change(function () {
		if (i == 0) {
			interval = setInterval(function () {
				moveRight();
			}, 3000);

			i = 1;
		} else {
			clearInterval(interval);
			i = 0;
		}


	});

	var slideCount = $('#slider ul li').length;
	var slideWidth = $('#slider ul li').width();
	var slideHeight = $('#slider ul li').height();
	var sliderUlWidth = slideCount * slideWidth;

	$('#slider').css({
		width: 1200,
		height: slideHeight
	});

	$('#slider ul').css({
		width: 1200,
	});

	$('#slider ul li:last-child').prependTo('#slider ul');

	function moveLeft() {
		$('#slider ul').animate({
			left: +slideWidth
		}, 200, function () {
			$('#slider ul li:last-child').prependTo('#slider ul');
			$('#slider ul').css('left', '');
		});
	};

	function moveRight() {
		$('#slider ul').animate({
			left: -slideWidth
		}, 200, function () {
			$('#slider ul li:first-child').appendTo('#slider ul');
			$('#slider ul').css('left', '');
		});
	};

	$('a.control_prev').click(function () {
		moveLeft();
	});

	$('a.control_next').click(function () {
		moveRight();
	});

});
